import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

class ScancodePage extends StatefulWidget {
  ScancodePage({Key key, this.result}) : super(key: key);
  String result = '';

  @override
  _ScancodePageState createState() => _ScancodePageState();
}

class _ScancodePageState extends State<ScancodePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          leading: BackButton(color: Colors.white),
          title: Text('扫描结果',
              style: TextStyle(
                color: Colors.white, //设置字体颜色
                fontSize: 20, //设置字体大小
              )),
        ),
        body: Column(
          children: [
            Container(
              width: MediaQuery.of(context).size.width,
              height: 180,
              padding: EdgeInsets.all(15),
              margin: EdgeInsets.only(left: 15, top: 15, right: 15),
              decoration: new BoxDecoration(
                //设置四周圆角 角度
                borderRadius: BorderRadius.all(Radius.circular(4.0)),
                //设置四周边框
                border: new Border.all(width: 1, color: Colors.orangeAccent),
              ),
              child: Text(widget.result,
                  style: TextStyle(
                    color: Colors.black, //设置字体颜色
                    fontSize: 20, //设置字体大小
                  )),
            ),
            SizedBox(height: 20),
            Center(
              child: RaisedButton(
                color: Colors.orangeAccent,
                child: new Text('复制',
                    style: TextStyle(
                        fontSize: 16, //设置字体大小
                        color: Colors.white)),
                onPressed: () {
                  // ...widget.result
                  ClipboardData data = new ClipboardData(text: widget.result);
                  Clipboard.setData(data);
                },
              ),
            )
          ],
        ));
  }
}
